/*    

    bobbietalk - a visual programming environment for toy robotics

    Copyright (C) 2013  Roberto Tiella

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

*/
package bobbietalk.gui.dialogs;

import javax.swing.InputVerifier;

/**
 *
 * @author tiella
 */
public class AttributePanel extends javax.swing.JPanel {

    private String attributeName;

    /**
     * Creates new form AttributePanel
     */
    public AttributePanel() {
        initComponents();
        
    }

    @Override
    public void setInputVerifier(InputVerifier inputVerifier) {
        valueTextField.setInputVerifier(inputVerifier);
    }

    
    
    public void setAttributeName(String name) {
        attributeName = name;
    }

    public String getAttributeName() {
        return attributeName;
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        attributeLabel = new javax.swing.JLabel();
        valueTextField = new javax.swing.JTextField();
        unitsLabel = new javax.swing.JLabel();

        attributeLabel.setText("jLabel1");

        valueTextField.setColumns(5);
        valueTextField.setText("jTextField1");

        unitsLabel.setText("unit");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(attributeLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(valueTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(unitsLabel)
                .addContainerGap(34, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(attributeLabel)
                    .addComponent(valueTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(unitsLabel))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel attributeLabel;
    private javax.swing.JLabel unitsLabel;
    private javax.swing.JTextField valueTextField;
    // End of variables declaration//GEN-END:variables

    public void setAttributeLabel(String name) {

        attributeLabel.setText(name);

    }

    public void setAttributeValue(String value) {

        valueTextField.setText(value);

    }

    public String getAttributeValue() {

        return valueTextField.getText();

    }

    void setUnits(String units) {
        unitsLabel.setText(units);
    }
}
